package servlet;

import java.io.IOException;

import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.ScrapService;
import service.UserService;
import vo.UserBean;

public class ScrapCheck extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
	// TODO Auto-generated method stub
String username=(String) req.getSession().getAttribute("username");
UserService us=new UserService();
 List<Object> userList = us.get(username);
 UserBean ub= (UserBean) userList.get(0);
 String level=ub.getLevel();
boolean ss = false;
ScrapService sps=new ScrapService();
 if(level.equals("1")){
	 List<Object> list = sps.getAll();
	 req.setAttribute("list", list);
	 ss=true;
 }else if(level.equals("2")){
	 List<Object> list = sps.get(username);
	 req.setAttribute("list", list);
	 ss=false;
 }
 req.setAttribute("level", level);
 
 req.getRequestDispatcher("/jsp/scrapCheck.jsp").forward(req, resp);

}
@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
	doGet(req, resp);
	}
}
